﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LWH.ByteProtocol
{
    public interface IProperty
    {

        /// <summary>
        /// 获取当前属性的byte长度
        /// </summary>
        /// <returns>当前属性的byte长度</returns>
        int getLength();

        /// <summary>
        /// 获取当前属性byte在协议byte数组中的起始位置
        /// </summary>
        /// <returns>起始位置</returns>
        int getOffset();

        /// <summary>
        /// 获取当前属性byte数据
        /// </summary>
        /// <returns>byte数据</returns>
        byte[] getData();

        /// <summary>
        /// 将指定的byte保存到属性
        /// </summary>
        /// <param name="data">保存的byte数组</param>
        /// <param name="offset">数据在byte数组中的起始位置</param>
        /// <param name="length">数据长度</param>
        void setData(byte[] data, int offset, int length);

        /// <summary>
        /// 当协议中存在当前属性时对属性的处理
        /// </summary>
        /// <param name="context">上下文</param>
        /// <returns>是否已处理数据，默认返回true</returns>
        bool handleProperty(Dictionary<String, Object> context);
    }
}
